PATHMac OS 8 and 9 Developer Documentation > Interapplication Communication > AppleScript for Scripters >

AppleScript Language Guide

   

With Timeout

By default, AppleScript waits one minute for a response before stopping execution of application and scripting addition commands that are sent to other applications. A With Timeout statement lets you change how long AppleScript waits.

SYNTAX
with timeout [ of ] integer second[s]
    [ statement ]...
end [ timeout ]

where

integer is an integer that specifies the amount of time, in seconds, AppleScript allows for each application command or command addition contained in the With Timeout statement that is sent to any application other than the current one.

statement is any AppleScript statement.

EXAMPLE

The following script starts the Finder on a task that may take a long time to complete. First it creates 40 folders, then it opens them, then it starts to close them, using a With Timeout statement to interrupt script execution one second after starting the Close operation. If the With Timeout statement generates an error, the error section of the Try statement calls the Beep scripting addition command and also writes "beep" to the Script Editor's Event Log window.

tell application "Finder"
    repeat 40 times
        make new folder at startup disk
    end repeat
    open (every folder of startup disk whose name contains "untitled")
    try
        with timeout of 1 second
            close (every folder of startup disk ¬
                whose name contains "untitled")
        end timeout
    on error
        --Just beep and notify Script Editor's Event Log window.
        beep
        log ("beep")
    end try
end tell

© 1999 Apple Computer, Inc. – (Last Updated 21 May 99)